package org.lanqiao.service.impl;
import org.lanqiao.entity.Admin;
import org.lanqiao.mapper.AdminMapper;
import org.lanqiao.mapper.PrivMapper;
import org.lanqiao.mapper.RoleMapper;
import org.lanqiao.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("adminService")
public class AdminServiceImpl implements AdminService {
	@Autowired
	AdminMapper adminMapper;
	@Autowired
	RoleMapper roleMapper;
	@Autowired
	PrivMapper privMapper;
	public Admin CheckUser(Admin admin2) {
		//第一步，校验用户和密码
		Admin admin = adminMapper.selectAdminByAnameAndPwd(admin2);
		if(admin != null) {
			admin.setLp(privMapper.selectPrivsByAid(admin.getId()));
			admin.setLr(roleMapper.selectRolesByAid(admin.getId()));
		}
		return admin;
	}

	public boolean updateAdminpwd(Admin admin) {
		// TODO Auto-generated method stub
		return adminMapper.updateAdminpwd(admin)>0;
	}


	public boolean updateAdminInfo(Admin admin) {
		// TODO Auto-generated method stub
		return adminMapper.updateAdminInfo(admin)>0;
	}

}
